using ASP;
using HoWave.Common;
using HoWave.Data;
using HoWave.Web;
using HoWave.Web.Shop.Member;
using System;
using System.Collections;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using Wuqi.Webdiyer;
public class Shop_Member_shop_review : Member, IRequiresSessionState
{
	public int UserID;
	public int NPage;
	public bool ImageClosed;
	public string wellpurchaserperson;
	public string wellbargainorperson;
	public string LastTimeLogin;
	public string m_flag = "0";
	protected RadioButtonList Review_Star_Select;
	protected DropDownList DropDownList_State;
	protected GridView GridViewReview;
	protected AspNetPager AspNetPager1;
	protected Button Button_Delete;
	protected Button Button_Success;
	protected Button Button_Error;
	protected Label Label_UserName;
	protected Label Label_DateTime;
	protected Label Label_ProductName;
	protected Label Label_Content;
	protected Label Label_Level;
	protected Button Button_Show;
	protected Button Button_Hidden;
	protected HtmlGenericControl DetailDiv;
	protected ObjectDataSource ReviewDataSource;
	protected ObjectDataSource ReviewDataSource0;
	protected HiddenField H_Review_Type;
	protected HiddenField H_Review_Star;
	protected HiddenField H_Review_UserID;
	protected HiddenField H_Review_ReviewerID;
	protected HiddenField H_SelectType;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		this.UserID = base.user.UserID;
		if (this.UserID > 0)
		{
			if (base.user.ShopID > 0)
			{
				if (!base.IsPostBack)
				{
					this.ViewState["Level"] = "";
					this.ViewState["State"] = "2";
					this.CommentBind("", "", base.user.ShopID, 0, 2);
					this.Review_Star_Select.Items.FindByValue("1").Selected = true;
				}
			}
		}
	}
	protected void CommentBind(string Level, string Content, int ShopID, int ProductID, int State)
	{
		Hashtable hashtable = new Hashtable();
		hashtable.Add("tblName", " [HLShop_Comment] as C,[HLShop_Product] as P,[HLShop_Shop] as S");
		hashtable.Add("seleName", "C.Id,C.UserName,P.ProductName,C.[DateTime],C.[Level],C.State,C.[Content],C.ShopID,C.ProductID");
		hashtable.Add("fldName", "DateTime");
		hashtable.Add("PageSize", 15);
		hashtable.Add("PageIndex", this.AspNetPager1.CurrentPageIndex);
		hashtable.Add("IsCount", 0);
		hashtable.Add("OrderType", 1);
		string text = "S.ShopID=C.ShopID AND C.ShopID=P.ShopID AND C.ProductID=P.ProductID AND C.ShopID=" + base.user.ShopID;
		if (Level != "")
		{
			text = text + " AND Level in (" + Level + ")";
		}
		if (State != 2)
		{
			text = text + "  AND State= " + State;
		}
		hashtable.Add("strWhere", text);
		Pager pager = new Pager();
		this.GridViewReview.DataSource = pager.Query(hashtable);
		this.GridViewReview.DataBind();
		this.AspNetPager1.AlwaysShow = true;
		this.AspNetPager1.PageSize = 15;
		hashtable.Remove("IsCount");
		hashtable.Add("IsCount", 1);
		this.AspNetPager1.RecordCount = pager.QueryRecordCount(hashtable);
	}
	protected void AspNetPager1_PageChanged(object sender, EventArgs e)
	{
		if (this.ViewState["Level"] != null)
		{
			this.CommentBind(this.ViewState["Level"].ToString(), "", 5, 0, Convert.ToInt32(this.ViewState["State"]));
		}
	}
	protected void Review_Star_Select_SelectedIndexChanged(object sender, EventArgs e)
	{
		string selectedValue = this.Review_Star_Select.SelectedValue;
		if (selectedValue != null)
		{
			if (!(selectedValue == "1"))
			{
				if (!(selectedValue == "2"))
				{
					if (!(selectedValue == "3"))
					{
						if (selectedValue == "4")
						{
							this.CommentBind("1,2", "", base.user.ShopID, 0, Convert.ToInt32(this.ViewState["State"]));
							this.ViewState["Level"] = "1,2";
						}
					}
					else
					{
						this.CommentBind("3", "", base.user.ShopID, 0, Convert.ToInt32(this.ViewState["State"]));
						this.ViewState["Level"] = "3";
					}
				}
				else
				{
					this.CommentBind("4,5", "", base.user.ShopID, 0, Convert.ToInt32(this.ViewState["State"]));
					this.ViewState["Level"] = "4,5";
				}
			}
			else
			{
				this.CommentBind("", "", base.user.ShopID, 0, Convert.ToInt32(this.ViewState["State"]));
			}
		}
	}
	protected void GridViewReview_RowCommand(object sender, GridViewCommandEventArgs e)
	{
		Shop_Comment shop_Comment = new Shop_Comment(this.conn);
		if (e.CommandName == "_Delete")
		{
			shop_Comment.DeleteComment(Convert.ToInt32(e.CommandArgument));
		}
		else
		{
			this.DetailDiv.Visible = true;
			int num = Convert.ToInt32(e.CommandArgument);
			this.ViewState["Id"] = num;
			DataTable attributesByID = shop_Comment.GetAttributesByID(num);
			this.Label_UserName.Text = attributesByID.Rows[0]["UserName"].ToString();
			this.Label_DateTime.Text = attributesByID.Rows[0]["DateTime"].ToString();
			this.Label_ProductName.Text = attributesByID.Rows[0]["ProductName"].ToString();
			this.Label_Content.Text = attributesByID.Rows[0]["Content"].ToString();
			this.Label_Level.Text = attributesByID.Rows[0]["Level"].ToString();
		}
	}
	protected void Button_Show_Click(object sender, EventArgs e)
	{
		int id = Convert.ToInt32(this.ViewState["Id"]);
		Shop_Comment shop_Comment = new Shop_Comment(this.conn);
		if (shop_Comment.UpdateComment(1, id))
		{
			this.WriteErrMsg("", "审核成功！", "shop_review.aspx");
		}
		else
		{
			this.WriteErrMsg("", "审核失败！", "shop_review.aspx");
		}
	}
	protected void Button_Hidden_Click(object sender, EventArgs e)
	{
		int id = Convert.ToInt32(this.ViewState["Id"]);
		Shop_Comment shop_Comment = new Shop_Comment(this.conn);
		if (shop_Comment.UpdateComment(0, id))
		{
			this.WriteErrMsg("", "审核成功！", "shop_review.aspx");
		}
		else
		{
			this.WriteErrMsg("", "审核失败！", "shop_review.aspx");
		}
	}
	protected void UserButtonOnCommon(object sender, CommandEventArgs e)
	{
		Shop_Comment shop_Comment = new Shop_Comment();
		string commandName = e.CommandName;
		if (commandName != null)
		{
			if (!(commandName == "_Delete"))
			{
				if (!(commandName == "_Success"))
				{
					if (commandName == "_Error")
					{
						if (base.Request["id"] != null && base.Request["id"] != string.Empty && base.Request["id"].ToString() != "")
						{
							string str = base.Request["id"].ToString();
							string sql = "UPDATE [HLShop_Comment] SET [State] = 0 WHERE [Id] IN(" + str + ")";
							bool flag = this.conn.Execute(sql) >= 1;
							if (flag)
							{
								this.WriteSuccessMsg("", Language.GetAdminMsg("Common/CheckSuccess"), "shop_review.aspx");
							}
						}
					}
				}
				else
				{
					if (base.Request["id"] != null && base.Request["id"] != string.Empty && base.Request["id"].ToString() != "")
					{
						string str = base.Request["id"].ToString();
						string sql = "UPDATE [HLShop_Comment] SET [State] = 1 WHERE [Id] IN(" + str + ")";
						bool flag = this.conn.Execute(sql) >= 1;
						if (flag)
						{
							this.WriteSuccessMsg("", Language.GetAdminMsg("Common/CheckSuccess"), "shop_review.aspx");
						}
					}
				}
			}
			else
			{
				if (base.Request["id"] != null)
				{
					string str = base.Request["id"].ToString();
					string sql = "DELETE FROM [HLShop_Comment] WHERE [Id] IN(" + str + ")";
					bool flag = this.conn.Execute(sql) >= 1;
					if (flag)
					{
						this.WriteSuccessMsg("", Language.GetAdminMsg("Common/DeleteSuccess"), "shop_review.aspx");
					}
				}
			}
		}
	}
	protected void DropDownList_State_SelectedIndexChanged(object sender, EventArgs e)
	{
		if (this.ViewState["Level"] != null)
		{
			this.CommentBind(this.ViewState["Level"].ToString(), "", base.user.ShopID, 0, int.Parse(this.DropDownList_State.SelectedValue));
			this.ViewState["State"] = this.DropDownList_State.SelectedValue;
		}
	}
}
